from .redisstorage import RedisStorage
from .localstorage import LocalStorage
from .prototypestorage import PrototypeStorage


class Storage(PrototypeStorage):
	def __init__(self):
		super().__init__()
		self.storage = RedisStorage()
		if self.storage.get_conn() is None:
			self.storage = LocalStorage()

	def add(self, proxy_data):
		self.storage.add(proxy_data)

	def delete(self, protocol, ip_port):
		self.storage.delete(protocol, ip_port)

	def get(self, protocol):
		return self.storage.get(protocol)

	def set(self, protocol, ip_port, proxy_data):
		self.storage.set(protocol, ip_port, proxy_data)
